import { createElement, LinkHTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { commentActionDefaultProps } from './defaultProps';
import type { CommentActionOptions } from './type';

export interface CommentActionProps extends CommentActionOptions, LinkHTMLAttributes<HTMLLinkElement> {}

const CommentAction: FC<CommentActionProps> = (props) => {
  const { className, active, children, forwardedRef, ...commentActionProps } = props;

  return createElement(
    'a',
    { ref: forwardedRef, className: classNames({ active }, className), ...commentActionProps },
    children,
  );
};

CommentAction.displayName = 'CommentAction';
CommentAction.defaultProps = commentActionDefaultProps;

export default CommentAction;
